package com.xfx.base;

import java.io.Serializable;

/**
 * 辅助分页查询结果
 * @author webb
 *
 */
public class Pagenation implements Serializable{

	private static final long serialVersionUID = 1L;
    public Pagenation(){}
    public Pagenation(int pageNo, int pageSize, int itemCount) {
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		this.itemCount = itemCount;
    }
	 
	/**
     * @return 每页条目数量
     */
	private int pageSize;
	
	/**
     * @return 当前页码
     */
	private int pageNo;
	
	/**
     * @return 条目总数
     */
	private int itemCount;
	
	/**
	 * @return 总页数
	 */
	private int pageCount;

    /**
     * 当查询起始行 从0开始
     */
    private int beginNum;

	private String order = "DESC";

    //延迟分钟数
    private int delayMinute = 0;

	public int getPageCount() {
		return  (int) Math.ceil(((double) itemCount / (double) pageSize));
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNo() {
        if(pageNo == 0) pageNo=1;
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getItemCount() {
		return itemCount;
	}

	public void setItemCount(int itemCount) {
		this.itemCount = itemCount;
	}

    public int getBeginNum() {
        return (pageNo-1) * pageSize;
    }

    public void setBeginNum(int beginNum) {
        this.beginNum = beginNum;
    }

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}

    public int getDelayMinute() {
        return delayMinute;
    }

    public void setDelayMinute(int delayMinute) {
        this.delayMinute = delayMinute;
    }
}
